<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>

        let money = 100;


        f();



        function f() {
            let atm = prompt('请输入你的操作' + '\n' + '1.存钱' + '\n' + '2.取钱' + '\n' + '3.显示余额' + '\n' + '4.退出')

            switch (atm) {
                case '1':
                    let saveMoney = parseFloat(prompt('请输入你要入存的钱数'));
                    money += saveMoney
                    alert('你的余额为' + money);
                    f()

                    break;
                case '2':
                    let widthdrawMoney = parseFloat(prompt('请输入你要取出的钱数'))
                    if (widthdrawMoney <= money) {
                        money -= widthdrawMoney
                        alert('你的余额为' + money)
                        f()
                    }
                    else {
                        alert('你的余额不足')
                        f()
                        break;
                    }
                case '3':
                    alert('你的余额为' + money)
                    f()
                    break;
                case '4':
                    alert('已退出')
                    break;

                default:
                    alert('无效操作')
                    break;
            }
        }






    </script>
</body>

</html>